package controllers

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type ResponseDataer interface {
	Response(c *gin.Context, Code ResCode)
	ResponseWithMsg(c *gin.Context, Code ResCode, msg string)
	ResponseSuccess(c *gin.Context, Code ResCode, data interface{})
}
type ResponseData struct {
	Code ResCode     `json:"code"`
	Msg  any `json:"msg"`
	Data any `json:"data"`
}

func Response(c *gin.Context, Code ResCode) {
	c.JSON(http.StatusOK, &ResponseData{
		Code: Code,
		Msg:  Code.GetMsg(),
		Data: nil,
	})
}
func ResponseWithMsg(c *gin.Context, Code ResCode, msg interface{}) {
	c.JSON(http.StatusOK, &ResponseData{
		Code: Code,
		Msg:  msg,
		Data: nil,
	})
}
func ResponseSuccess(c *gin.Context, Code ResCode, data interface{}) {
	c.JSON(http.StatusOK, &ResponseData{
		Code: Code,
		Msg:  "",
		Data: data,
	})
}
